import { Prefab } from 'cc';
import { tween } from 'cc';
import { Animation } from 'cc';
import { bezier } from 'cc';
import { instantiate } from 'cc';
import { Vec3 } from 'cc';
import { _decorator, Component, Node } from 'cc';
import { eliminateGameManager } from './EliminateGameManager';
const { ccclass, property } = _decorator;

@ccclass('EliminateEffect')
export class EliminateEffect extends Component {

    @property(Prefab)
    starPrefab: Prefab = null;

    protected __preload(): void {
        eliminateGameManager.effectManager = this;
    }

    /**
     * 
     * 生成小星星到分数界面
     * 
     */
    generateStarToScore(score: number) {
        const starNode = instantiate(this.starPrefab);
        this.node.addChild(starNode);
        const animation = starNode.getComponent(Animation);
        const state = animation.getState("score_star");
        state.speed = 0.5;

        const animState = animation.play();
        animation.on(Animation.EventType.FINISHED, () => {
            animation.node.destroy();
        }, this);
    }

    start() {

    }

    update(deltaTime: number) {

    }
}

